<?php
	include_once("../include/init.php");
 	extract($_POST);
//从表单提交
	if(!isset($sub)){
		msg("请从表单提交","regist.php");
	}
	//数据处理
	$username = trim($username);
	$password = md5(trim($password));
	$pwd = md5(trim($pwd));
	$tel = trim($tel);
	$email = trim($email);
	//数据库处理
	$sql = "select user from tk_user where user = '$username'";
  	$re=mysql_query($sql);
 if(mysql_num_rows($re)>0){
 	msg("用户名重复","regist.php");
 	exit;
 }
 $ins = "insert into tk_user(user,password,phone,email) values('$username','$password','$tel','$email')";
	//echo $ins;exit;
  $res = mysql_query($ins);
  if(mysql_affected_rows()>0){
	header("location: login.php");
  }
  else{
  	msg ("注册失败","regist.php");
  }

?>